/**
 * Copyright (C) 2010 Sergey Grigoriev <s.a.grigoriev@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.gmf.examples.resourceModule.consumer {
import flash.events.IEventDispatcher;

import mx.controls.Text;
import mx.events.ResourceEvent;
import mx.resources.IResourceManager;
import mx.resources.ResourceManager;
import org.flexunit.Assert;

public class Test {

    static var target:Text

    private function get rm():IResourceManager {
        return ResourceManager.getInstance()
    }

    private function checkResourceModule(expected:String,locale:String,resourceModuleURL:String):void {

        var eventDispatcher:IEventDispatcher = rm.loadResourceModule(resourceModuleURL);
        eventDispatcher.addEventListener(ResourceEvent.COMPLETE, function(e:ResourceEvent){
            rm.localeChain = [ locale ]
            Assert.assertEquals(expected, target.text)
        });
    }

    [Test]
    public function testResourceModules():void {
        checkResourceModule('France','fr_FR','module_fr.swf')
        checkResourceModule('Россия','ru_RU','module_ru.swf')
    }
}
}